package com.example.demo.service.impl;

import com.example.demo.common.ResponseMessage;
import com.example.demo.dao.CartMapper;
import com.example.demo.pojo.Cart;

import com.example.demo.service.ICartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("iCartService")
public class CartServiceImpl implements ICartService {

   @Autowired
    private CartMapper cartMapper;


    @Override
    public ResponseMessage getCartList(int userId) {
        List<Cart> orderList = cartMapper.selectAll(userId);
        ResponseMessage msg = new ResponseMessage(orderList);
        return msg;
    }

    @Override
    public int addCart(int productId, int quantity,int userId) {
        return cartMapper.insertbyproductid(productId, quantity, userId);
    }
    @Override
    public int updateByCart(int product_id, int quantity, int userId) {
        Cart cart = new Cart();
        return cartMapper.updateByCart(product_id, quantity, userId);
    }

    @Override
    public int deleteProduct(Integer product_id) {
        return cartMapper.deleteProduct(product_id);
    }

    @Override
    public int updateByChecked(Integer product_id) {
        return cartMapper.updateByChecked(product_id);
    }

    @Override
    public int updateByNOChecked(Integer product_id) {
        return cartMapper.updateByNOChecked(product_id);
    }

    @Override
    public List<Cart> selectNum(Integer user_id) {
        return cartMapper.selectNum(user_id);
    }


    @Override
    public int updateBll(Integer user_id) {
        return cartMapper.updateBll(user_id);
    }

    @Override
    public int updateNOBll(Integer user_id) {
        return cartMapper.updateNOBll(user_id);
    }
}